package com.dream.dao.base;

/**
 * 
 * @author Evan
 * @date 2013-8-25
 * 
 */
import java.util.List;

import org.springframework.stereotype.Repository;

import com.dream.model.app.AppImage;
import com.dream.model.app.AppImage.ImageStatus;
import com.dream.utils.hibernate.DetachedCriteriaBuilder;
import com.dream.utils.hibernate.DreamBaseDAO;

@Repository
public class AppImageDAO extends DreamBaseDAO<AppImage> {
	
	public AppImage getImageById(Long id){
		
		DetachedCriteriaBuilder builder = DetachedCriteriaBuilder.instance(AppImage.class);
		builder.addEq("status", ImageStatus.normal).addEq("id", id);
		return selectTopOne(builder);
	}
	
	public List<AppImage> getAllImages(){
		
		DetachedCriteriaBuilder builder = DetachedCriteriaBuilder.instance(AppImage.class);
		builder.addEq("status", ImageStatus.normal);
		return select(builder);
		
	}

}
